package cn.jetpiece.cloud.log.api;

import cn.jetpiece.cloud.log.api.model.params.GatewayLogParam;
import cn.jetpiece.cloud.log.api.model.query.GatewayLogQuery;
import cn.jetpiece.cloud.log.api.model.result.GatewayLogInfoResult;
import cn.jetpiece.cloud.log.api.model.result.GatewayLogResult;
import cn.jetpiece.cloud.model.page.PageResult;
import cn.jetpiece.cloud.model.response.Result;
import cn.jetpiece.cloud.resource.annotation.annotation.ApiResource;
import cn.jetpiece.cloud.resource.annotation.annotation.ScanResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import java.util.Date;


/**
 * 网关日志接口
 *
 * @author XuJZ
 */
@Api(tags = "网关日志")
@ApiResource(name = "网关日志")
public interface GatewayLogApi {

    String API = "/log/gatewayLogs";
    /**
     * 日志队列
     */
    String GATEWAY_LOG_CACHE = "LOG_QUEUE:GATEWAY_LOG";

    /**
     * 新增网关日志
     *
     * @param param 新增参数
     * @return 返回结果
     */
    @ApiOperation(value = "新增网关日志")
    @ScanResource(name = "新增网关日志", path = API, method = RequestMethod.POST)
    Result<String> add(@RequestBody @Valid GatewayLogParam param);

    /**
     * 删除网关日志
     *
     * @param id 主键
     * @param requestTimeStart 请求开始时间
     * @return 返回结果
     */
    @ApiOperation(value = "删除网关日志")
    @ScanResource(name = "删除网关日志", path = API + "/{id}", method = RequestMethod.DELETE)
    Result<String> delete(@PathVariable(name = "id") Long id, @ApiParam(value = "请求开始时间", required = true) @RequestParam(value = "companyId") Date requestTimeStart);

    /**
     * 查询网关日志请求信息
     *
     * @param id               主键
     * @param requestTimeStart 请求开始时间
     * @return 返回结果
     */
    @ApiOperation(value = "查询网关日志请求信息")
    @ScanResource(name = "查询网关日志请求信息", path = API + "/{id}/info", method = RequestMethod.GET)
    Result<GatewayLogInfoResult> getInfo(@PathVariable(name = "id") Long id, @ApiParam(value = "请求开始时间", required = true) @RequestParam(value = "requestTimeStart") Date requestTimeStart);

    /**
     * 分页获取网关日志
     *
     * @param query 查询条件
     * @return 返回结果
     */
    @ApiOperation(value = "分页获取网关日志")
    @ScanResource(name = "分页获取网关日志", path = API, method = RequestMethod.GET)
    Result<PageResult<GatewayLogResult>> page(@Valid @SpringQueryMap GatewayLogQuery query);

}
